package org.edu.modules.growth.controller;//package org.edu.modules.growth.controller;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.edu.common.api.vo.Result;
import org.edu.common.system.base.controller.BaseController;
import org.edu.modules.growth.dto.VeJsczUateDTO;
import org.edu.modules.growth.dto.VeJsczUateEditDTO;
import org.edu.modules.growth.entity.VeJsczUate;
import org.edu.modules.growth.service.IVeJsczUateService;
import org.edu.modules.growth.vo.QueryCondition;
import org.edu.modules.growth.vo.TeacherVo;
import org.edu.modules.growth.vo.VeJsczUateVo;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags="教职工考核管理-考核结果管理")
@RestController
@RequestMapping("jsczUate")
@Slf4j
@AllArgsConstructor
public class VeJsczUateController extends BaseController<VeJsczUate, IVeJsczUateService> {

    private IVeJsczUateService mIVeJsczUateService;


    /**
     * 根据学期及专业组获取未评审的教师数据
     */
    @ApiOperation(value = "根据学期及专业组获取未评审的教师数据")
    @PostMapping("/getTeachers")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "semId", value = "学期Id", dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "zyzId", value = "专业组Id", dataType = "String")
    })
    public Result<List<TeacherVo>> getTeachers(@RequestParam("semId") String semId, @RequestParam("zyzId") String zyzId) {
        return Result.OK();
    }


    /**
     * 提交评审数据
     */
    @ApiOperation(value = "提交评审数据")
    @PostMapping("/submit")
    public Result<?> submit(@RequestBody VeJsczUateDTO dto) throws Exception {
        mIVeJsczUateService.submit(dto);
        return Result.OK();
    }

    /**
     * 分页查询信息
     */
    @ApiOperation(value = "分页查询信息")
    @PostMapping("/selectPage")
    public Result<?> selectPage(@RequestBody QueryCondition queryCondition ) {
        return Result.OK(mIVeJsczUateService.selectPage(queryCondition));
    }

    /**
     * 根据id详情
     */
    @ApiOperation(value = "查询详情（根据结果id）")
    @PostMapping("/getDetail")
    public Result<VeJsczUateVo> getDetail(@RequestParam("id") Long id) {
        return Result.OK(mIVeJsczUateService.getDetailById(id));
    }


    /**
     * 删除
     */
    @ApiOperation(value = "删除")
    @PostMapping("/removeById")
    public Result<?> removeById(@RequestParam("id") Long id) {
        mIVeJsczUateService.deleteById(id);
        return Result.OK(  );
    }

    /**
     * 批量删除
     * @return
     */
    @ApiOperation(value = "批量删除")
    @PostMapping("/removeByIds")
    public Result<?> removeByIds(@RequestBody List<Long> ids) {
        if( !CollectionUtils.isEmpty(ids) ){
            mIVeJsczUateService.removeLogicByIds(ids) ;
            return Result.OK();
        }
        return Result.error( "传输参数为空！" );
    }

    /**
     * 修改
     */
    @ApiOperation(value = "修改评审数据")
    @PostMapping("/edit")
    public Result<?> edit(@RequestBody VeJsczUateEditDTO dto) throws Exception {
        VeJsczUate ve = mIVeJsczUateService.getById(dto.getId()) ;
        if( ve == null ){
            return Result.error("未找到信息！");
        }
        mIVeJsczUateService.edit(dto,ve);
        return Result.OK();
    }


}
